package com.demo.service_admin.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.demo.dao_admin.UserDAO;
import com.demo.entity.User;
import com.demo.service_admin.UserService;

@Service("adminUserService")
public class UserServiceImpl implements UserService {

	@Resource
	UserDAO adminUserDAO;


	@Override
	public User save(User user) {
		return adminUserDAO.save(user);
	}

	@Override
	public void delete(Long id) {
		adminUserDAO.deleteById(id);
	}

	@Override
	public List<User> findAll() {
		return adminUserDAO.findAll();
	}

	@Override
	public User findById(Long id) {
		return adminUserDAO.findById(id).get();
	}

	@Override
	public User findByUsername(String username) {
		return adminUserDAO.findByUsername(username);
	}

	@Override
	public List<User> findByBirthBetween(Date birth, Date birth2) {
		return adminUserDAO.findByBirthBetween(birth, birth2);
	}

	@Override
	public Page<User> findByUsernameLike(String username, Pageable pageable) {
		return adminUserDAO.findByUsernameLike(username, pageable);
	}

//	@Override
//	public Page<User> search(Pageable pageable, User user) {
//		return adminUserDAOImpl.search(pageable, user);
//	}

}